<template>
  <div class="add-card">
    <header class="add-header">
      <el-page-header content="查看详情" @back="$router.back()" />
    </header>
    <main class="add-main">
      <div class="form-container">
        <div class="title">车辆信息</div>
        <div class="form">
          <el-descriptions :column="2">
            <el-descriptions-item label="车主姓名">{{ carInfo.personName }}</el-descriptions-item>
            <el-descriptions-item label="联系方式">{{ carInfo.phoneNumber }}</el-descriptions-item>
            <el-descriptions-item label="车牌号码">{{ carInfo.carNumber }}</el-descriptions-item>
            <el-descriptions-item label="车辆品牌">{{ carInfo.carBrand }} </el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
      <div class="form-container">
        <div class="title">月卡缴费记录</div>
        <el-table :data="payList" style="width:100%" class="from">
          <el-table-column type="index" label="序号" width="180" />
          <el-table-column prop="validity" label="有效期" width="180" />
          <el-table-column prop="paymentAmount" label="支付金额" />
          <el-table-column prop="paymentMethod" label="支付方式" />
          <el-table-column prop="createTime" label="办理时间" />
          <el-table-column prop="createUser" label="办理人" />
        </el-table>
      </div>
    </main>
  </div>
</template>

<script>
import { checkCard } from '@/apis/card'
export default {
  data() {
    return {
      // 车辆信息表单
      carInfo: [],
      payList: []
    }
  },
  computed: {
    id() {
      return this.$route.query.id
    }
  },
  async created() {
    const res = await checkCard(this.id)
    console.log(res)
    this.carInfo = res.data
    this.payList = res.data.rechargeList
    this.payList.map(ele => {
      ele.validity = ele.cardStartDate + '至' + ele.cardEndDate
    })
    console.log(this.payList)
  }
}
</script>

<style scoped lang="scss">
.add-card {
  background-color: #f4f6f8;
  height: 100vh;

  .add-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    background-color: #fff;

    .left {
      span {
        margin-right: 4px;
      }
      .arrow {
        cursor: pointer;
      }
    }

    .right {
      text-align: right;
    }
  }

  .add-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
      background-color: #fff;

      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
      }
      .form {
        margin-bottom: 60px;
        padding: 20px 65px 24px;

        .el-form {
          display: flex;
          flex-wrap: wrap;

          .el-form-item {
            width: 50%;
          }
        }
      }
    }
    .preview {
      img {
        width: 100px;
      }
    }
  }

  .add-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    padding: 24px 50px;
    color: #000000d9;
    font-size: 14px;
    background: #fff;
    text-align: center;
  }
}
</style>
